package com.xmy.cultivate.schedule;

import com.xmy.cultivate.service.IEnrollInviteDetailService;
import com.xmy.cultivate.util.SpringUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;

public class UpdateCustomerStatusJob implements Job {

    @Autowired
    IEnrollInviteDetailService iEnrollInviteDetailService = SpringUtils.getBean(IEnrollInviteDetailService.class);;

    private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    private void before() {
        System.out.println("任务TranscriptJob：开始执行-" + dateFormat.format(new Date()));
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        LocalDate schoolDate = LocalDate.now().minusDays(1);//减去1天
        iEnrollInviteDetailService.actionUpdateCustomer(schoolDate);
    }
    private void after() {
        System.out.println("任务TranscriptJob：执行结束");
        System.out.println();
    }
}
